Tomáš Pospíšek's Notizblock

Reinventing the wheel

Damnit! I just want to publish some little thoughts from time to time on the net. Then why must the software to do so be so bloody complicated?

:-(

Thus, frustrated, I did my own blogging "software".

#!/bin/sh
#
# using the very nice "Markup.pl" from
# http://daringfireball.net/projects/markdown/syntax

block_home=~/doc/interest/block
block_header=$block_home/head.html
block_src=$block_home/index.markdown
block_out=$block_home/index.html
block_dst=block:web/

vim $block_home/index.markdown
cat $block_src | markdown > $block_out

prepend () { # header to_file
  header=$1
  to_file=$2
  tmp=`mktemp`
  cat $header $to_file > $tmp
  mv $tmp $to_file
}

postprocess() {

  # replace $sig
  #date=`date -R`
  #signature="Tomáš Pospíšek, $date"
  signature="Tomáš Pospíšek"
  sed --in-place "s/\$sig/$signature/" $block_out

  # process $includes
  # http://www.unix.com.ua/orelly/perl/cookbook/ch07_10.htm
  perl -ni -e 'if( /\$include(\s*)"(\S*)"/ ) {
                    print `cat $2`; next; }
               else {
                    print; }'     $block_out

  prepend $block_header $block_out
}

postprocess

ask_for_confirmation -y "publish?" || exit
scp $block_out $block_dst

firefox http://tpo.sourcepole.ch

:-)

Thanks to John Gruber for Markdown.pl and for some of the fine CSS I'm using here.

Tomáš Pospíšek, 2008-11-07

Articles